# 
# CONFIGURE.AC - used by autoconf to prepare the configure script
#

#
# Initialization
#
AC_PREREQ(2.56)                            # Autoconf 2.56 minimum
AC_INIT([citymanager],[0.3])               # Initialize autoconf
AM_INIT_AUTOMAKE([-Wall -Werror])          # Initialize automake
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
AM_GNU_GETTEXT_VERSION([0.17])
AM_GNU_GETTEXT([external])

# Get standard files
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADERS([config.h])


# 
# Check for programs
#
AC_PROG_CC         # C compiler
AC_PROG_MAKE_SET   # Make
AC_HEADER_STDC     # Standard headers
AC_HEADER_STDBOOL  # stdbool.h (C99)
AC_TYPE_UINT8_T    # uint8_t

#
# Checks for libraries.
#

# SDL
SDL_VERSION=1.2.0
AM_PATH_SDL($SDL_VERSION, 
         :,
         AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]) 
) 
CFLAGS="$CFLAGS $SDL_CFLAGS" 
LIBS="$LIBS $SDL_LIBS"

# SDL_ttf
AC_CHECK_LIB([SDL_ttf], [TTF_Init], [SDL_TTF_LIBS=-lSDL_ttf], [AC_MSG_ERROR([SDL_ttf was not found in the system.])])
AC_SUBST([SDL_TTF_LIBS])

# SDL_image
AC_CHECK_LIB([SDL_image], [IMG_Init], [SDL_IMAGE_LIBS=-lSDL_image], [AC_MSG_ERROR([SDL_image was not found in the system.])])
AC_SUBST([SDL_IMAGE_LIBS])

# SQLite3
AC_CHECK_LIB([sqlite3], [sqlite3_open], [SQLITE3_LDFLAGS=-lsqlite3], [AC_MSG_ERROR([SQLite3 was not found in the system.])])
AC_SUBST([SQLITE3_LDFLAGS])


#
# Prepare makefiles
#
AC_CONFIG_FILES([Makefile src/Makefile data/Makefile po/Makefile.in m4/Makefile])
AC_OUTPUT
